Emacs should no longer hang at startup on kFreeBSD.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 21 Aug 2013 05:39:51 +0000 (22:39 -0700)
committerRob Browning <rlb@defaultvalue.org>
Thu, 26 Sep 2013 18:41:37 +0000 (13:41 -0500)
Applied upstream patch (in conjunction with 5113964):

  * process.c (allocate_pty) [PTY_OPEN]: Set fd's FD_CLOEXEC flag.

  We can't portably rely on PTY_OPEN doing that, even if
  it calls posix_openpt with O_CLOEXEC.

Origin: upstream, commit: 511396357c5937ff85bce49f9dc8f4c66851620416bdc07
Added-by: Rob Browning <rlb@defaultvalue.org>
Provided-By: Paul Eggert <eggert@cs.ucla.edu>
Bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15129

src/ChangeLog
src/process.c

index 588f2933eff9973589973d0d82ea37d0354f6191..921d411082bbcc92bcf490153692e789c18a0d9b 100644 (file)
@@ -1,3 +1,9 @@
+2013-08-21  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * process.c (allocate_pty) [PTY_OPEN]: Set fd's FD_CLOEXEC flag.
+       We can't portably rely on PTY_OPEN doing that, even if
+       it calls posix_openpt with O_CLOEXEC.
+
 2013-03-11  Glenn Morris  <rgm@gnu.org>
 
        * Version 24.3 released.
index 2fb5b16a19ff68a5bf4ac54f463a5139b8e7e23d..f6abf0ce8b5af32d04365acd14573f7aa12410ac 100644 (file)
@@ -661,6 +661,15 @@ allocate_pty (void)
 
        if (fd >= 0)
          {
+#ifdef PTY_OPEN
+           /* Set FD's close-on-exec flag.  This is needed even if
+              PT_OPEN calls posix_openpt with O_CLOEXEC, since POSIX
+              doesn't require support for that combination.
+              Multithreaded platforms where posix_openpt ignores
+              O_CLOEXEC (or where PTY_OPEN doesn't call posix_openpt)
+              have a race condition between the PTY_OPEN and here.  */
+           fcntl (fd, F_SETFD, FD_CLOEXEC);
+#endif
            /* check to make certain that both sides are available
               this avoids a nasty yet stupid bug in rlogins */
 #ifdef PTY_TTY_NAME_SPRINTF